﻿////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// <copyright>Copyright 2008-2011 Andreas Huber Doenni</copyright>
// Distributed under the GNU General Public License version 2 (GPLv2).
// See accompanying file License.txt or copy at http://phuse.codeplex.com/license.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

namespace Phuse.Net.Forums
{
    using System;

    /// <summary>Holds context information for the construction of <see cref="SendReceiveHelper{T}"/> subclass
    /// objects.</summary>
    /// <threadsafety static="true" instance="false"/>
    public sealed class SendReceiveContext
    {
        private readonly Func<Database> openDatabase;
        private readonly int groupId;

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        internal SendReceiveContext(Func<Database> openDatabase, int groupId)
        {
            this.openDatabase = openDatabase;
            this.groupId = groupId;
        }

        internal void ReopenDatabase(ref Database database, out Group group, out Root root)
        {
            Cache.ReopenDatabase(this.openDatabase, this.groupId, ref database, out group, out root);
        }
    }
}
